home *** CD-ROM | disk | FTP | other *** search
- unit Shapesu;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, ExtCtrls, StdCtrls;
-
- type
- TForm1 = class(TForm)
- procedure FormKeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
- begin
- { The variable with no name! }
- with TShape.Create(Self) do
- begin
- Left := 0;
- Top := 0;
- { For Random to be truly random, we call }
- { Randomize in the initialization section }
- Width := Random(Self.ClientWidth);
- Height := Random(Self.ClientHeight);
- Brush.Color := RGB(Random(256), Random(256), Random(256));
- Shape := TShapeType(Random(6));
- Parent := Self;
- end;
- { We've done all that we want doing on this key press }
- { Null the key to prevent any further key-press processing }
- Key := #0;
- end;
-
- initialization
- Randomize;
- end.
-